import 'dart:convert' show json;

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }

  return null;
}

class HomeM {
  HomeM({
    this.c,
    this.h,
    this.lastQty,
    this.m,
    this.notice,
    this.s,
    this.status,
    this.t,
  });

  factory HomeM.fromJson(Map<String, dynamic> jsonRes) {
    if (jsonRes == null) {
      return null;
    }

    final List<HomeVideoM> c = jsonRes['c'] is List ? <HomeVideoM>[] : null;
    if (c != null) {
      for (final dynamic item in jsonRes['c']) {
        if (item != null) {
          c.add(HomeVideoM.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }

    final List<HomeVideoM> h = jsonRes['h'] is List ? <HomeVideoM>[] : null;
    if (h != null) {
      for (final dynamic item in jsonRes['h']) {
        if (item != null) {
          h.add(HomeVideoM.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }

    final List<HomeVideoM> m = jsonRes['m'] is List ? <HomeVideoM>[] : null;
    if (m != null) {
      for (final dynamic item in jsonRes['m']) {
        if (item != null) {
          m.add(HomeVideoM.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }

    final List<HomeVideoM> s = jsonRes['s'] is List ? <HomeVideoM>[] : null;
    if (s != null) {
      for (final dynamic item in jsonRes['s']) {
        if (item != null) {
          s.add(HomeVideoM.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }

    final List<HomeVideoM> t = jsonRes['t'] is List ? <HomeVideoM>[] : null;
    if (t != null) {
      for (final dynamic item in jsonRes['t']) {
        if (item != null) {
          t.add(HomeVideoM.fromJson(asT<Map<String, dynamic>>(item)));
        }
      }
    }
    return HomeM(
      c: c,
      h: h,
      lastQty: asT<int>(jsonRes['lastQty']),
      m: m,
      notice: asT<String>(jsonRes['notice']),
      s: s,
      status: asT<int>(jsonRes['status']),
      t: t,
    );
  }

  List<HomeVideoM> c;
  List<HomeVideoM> h;
  int lastQty;
  List<HomeVideoM> m;
  String notice;
  List<HomeVideoM> s;
  int status;
  List<HomeVideoM> t;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'c': c,
        'h': h,
        'lastQty': lastQty,
        'm': m,
        'notice': notice,
        's': s,
        'status': status,
        't': t,
      };
  @override
  String toString() {
    return json.encode(this);
  }
}

class HomeVideoM {
  HomeVideoM({
    this.vodID,
    this.vodName,
    this.vodPic,
    this.vodYear,
    this.vodArea,
    this.vodRemarks,
    this.vodHits,
    this.vodActor,
    this.vodDirector,
    this.vodTime,
    this.vodTypeID,
    this.vodClass,
  });

  factory HomeVideoM.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : HomeVideoM(
          vodID: asT<int>(jsonRes['VodID']),
          vodName: asT<String>(jsonRes['VodName']),
          vodPic: asT<String>(jsonRes['VodPic']),
          vodYear: asT<String>(jsonRes['VodYear']),
          vodArea: asT<String>(jsonRes['VodArea']),
          vodRemarks: asT<String>(jsonRes['VodRemarks']),
          vodHits: asT<int>(jsonRes['VodHits']),
          vodActor: asT<String>(jsonRes['VodActor']),
          vodDirector: asT<String>(jsonRes['VodDirector']),
          vodTime: asT<int>(jsonRes['VodTime']),
          vodTypeID: asT<int>(jsonRes['VodTypeID']),
          vodClass:
              VodClass.fromJson(asT<Map<String, dynamic>>(jsonRes['VodClass'])),
        );

  int vodID;
  String vodName;
  String vodPic;
  String vodYear;
  String vodArea;
  String vodRemarks;
  int vodHits;
  String vodActor;
  String vodDirector;
  int vodTime;
  int vodTypeID;
  VodClass vodClass;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'VodID': vodID,
        'VodName': vodName,
        'VodPic': vodPic,
        'VodYear': vodYear,
        'VodArea': vodArea,
        'VodRemarks': vodRemarks,
        'VodHits': vodHits,
        'VodActor': vodActor,
        'VodDirector': vodDirector,
        'VodTime': vodTime,
        'VodTypeID': vodTypeID,
        'VodClass': VodClass,
      };
  @override
  String toString() {
    return json.encode(this);
  }
}

class VodClass {
  VodClass({
    this.typeID,
    this.typeName,
  });

  factory VodClass.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : VodClass(
          typeID: asT<int>(jsonRes['TypeID']),
          typeName: asT<String>(jsonRes['TypeName']),
        );

  int typeID;
  String typeName;

  Map<String, dynamic> toJson() => <String, dynamic>{
        'TypeID': typeID,
        'TypeName': typeName,
      };
  @override
  String toString() {
    return json.encode(this);
  }
}
